﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace LHWebApp
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Response.ContentType = "text/plain";
                string userName = Request.Params["loginUsername"];
                string passWord = Request.Params["loginPassword"];
                string isLogin = Request.Params["isLogin"];
                UserInfo userInfo = Services.Login(userName, passWord);
                if (userInfo != null)
                {
                    Session["CurrentUserInfo"] = userInfo;
                    userInfo.loginUsername = userName;
                    userInfo.loginPassword = passWord;

                    GetLoginInfo first = (GetLoginInfo)Session["GetLoginInfo"];
                    if (isLogin != "5566")
                    {
                        first = new GetLoginInfo();
                        first.isFirst = "NO";
                        first.firstClientNo = userInfo.ClientNo;
                        Session["GetLoginInfo"] = first;
                    }
                    userInfo.firstClientNo = first.firstClientNo;
                    Response.Write(userInfo.loginUsername + "," + userInfo.ClientNo);
                }
                else
                    Response.Write("{failure:true,reason:'登录失败，帐号或密码不正确!',action:'1'}");

            }
        }
    }
}
